import 'dart:ui';

import 'package:flutter/material.dart';

class CarbodyPage extends StatefulWidget {
  CarbodyPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<CarbodyPage> {
  List formList;
  initState() {
    super.initState();
    formList = [
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},{"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
      {"title": '左前A柱', 'status': '正常'},
    ];
  }

  Widget buildcontent() {
    List<Widget> tiles = [];
    Widget content;
    for (var item in formList) {
      tiles.add(new Row(children: <Widget>[
        Expanded(child:
        new Padding(
            padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
            child: new Text(
              item['title'],
              style: TextStyle(fontSize: 16),
            )),flex: 3,),
             new Padding(
            padding: new EdgeInsets.fromLTRB(10, 10, 10, 0),
            child: new Text(
              item['status'],
              style: TextStyle(fontSize: 16,color: Color.fromRGBO(27, 182, 251, 1)),
            )),
      ],));
    }
    content = new Column(
        children: tiles //重点在这里，因为用编辑器写Column生成的children后面会跟一个<Widget>[]，
        //此时如果我们直接把生成的tiles放在<Widget>[]中是会报一个类型不匹配的错误，把<Widget>[]删了就可以了
        );
    return content;
  }

  Widget build(BuildContext context) {
    return new MaterialApp(
      title: '结构件',
      home: new Scaffold(
          appBar: new AppBar(
            title: new Text('结构件'),
            backgroundColor: Color.fromRGBO(255, 204, 48, 1),
          ),
          body: new Center(
            child: new ListView(children: <Widget>[buildcontent()],),
          )),
    );
  }
}
